package com.javaGather.day3;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class Test1 {
    public static void main(String[] args) {
        /**
         * 迭代器  集合专用
         */

        List<String> objects = new ArrayList<>();
        objects.add("Hello");
        objects.add("World");
        objects.add("Java");

        IteratorDemo iteratorDemo = new IteratorDemo(objects);
//        System.out.println(iteratorDemo.next());
//        System.out.println(iteratorDemo.next());
//        System.out.println(iteratorDemo.next());

        if (iteratorDemo.hasNext()) {
            System.out.println(iteratorDemo.next());
        }
        if (iteratorDemo.hasNext()) {
            System.out.println(iteratorDemo.next());
        }
        if (iteratorDemo.hasNext()) {
            System.out.println(iteratorDemo.next());
        }

        //iterator.hasNext()为false
        if (iteratorDemo.hasNext()) {
            System.out.println(iteratorDemo.next());
        }

    }
}
